def prime(num):
    if num < 2:
        return False
    for i in range(2, int(num ** 0.5) + 1):
        if num % i == 0:
            return False
    return True

def number(word1, word2, word3):
    numbers = {"zero": 0, "one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "seven": 7, "eight": 8,
               "nine": 9}

    if word1 in numbers and word2 in numbers and word3 in numbers:
        num = numbers[word1] * 100 + numbers[word2] * 10 + numbers[word3]-5
        if num >= 100 and num <= 999:
            for i in range(num, 1000):
                if prime(i):
                    print(i)
                    break
        else:
            print("Wrong input")
    else:
        print("Wrong input")

input_words = input().split()
if len(input_words) ==3:
    word1, word2, word3 = input_words
    number(word1, word2, word3)
else:
    print("Wrong input")